package com.common.springbootcommonmessage.enums;



import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;

public enum AutoBestErrorCode {
    /**
     * All server error should be 1xxxxxx
     */
    BACKEND_DATA_CODE(100000),
    INTERNAL_SERVER_ERROR(100001),

    /**
     * This is a sample, All user error should be 2xxxxxx
     */
    ARGUMENT_INVALID(200001),
    REQUEST_BODY_MISSING(200002),
    RESOURCE_NOT_FOUND(200003),
    PARAMS_CAN_NOT_EMPTY(200004),
    USER_HAS_EXIST(200005),
    USER_NOT_EXIST(200006),
    USER_PASSWORD_ERROR(200007),
    USER_UNAUTHORIZED(200008),
    ELEMENT_HAS_EXIST(200009),

    ORDER_VALIDATE_PART_NOT_EXIST(400001),
    ORDER_FAILED_TO_CHARGE(400002),
    ORDER_ALL_VALIDATE_ERROR(400003),
    ORDER_VALIDATE_OVER_FIVE_PARTS(400004),
    ORDER_VALIDATE_REPLACE_PARTS(400005),
    ORDER_VALIDATE_QTY_NOT_MATCH(400006),
    ORDER_CHARGE_CUSTOMER_FAILED(400007),
    ORDER_VERIFY_OVERNIGHT_ERROR(400008),
    ORDER_CREATE_LABEL_FAILED_ERROR(400009),
    ORDER_PICKUP_FAILED_ERROR(400010),

    // All Exception error code should be start with 500xxx, Others error code cannot use
    API_DB_DISCONNECTED_ERROR_CODE(500000),
    API_EXCEPTION_ERROR_CODE(500001),
    API_HTTPCALL_ERROR_CODE(500002),

    INFORMATION_HINTS(600001),
    REFERENCE_NUMBER_IS_EMPTY(600002),
    REFERENCE_NUMBER_EXIST(600003),
    INVOICE_TOTAL_OVER_CHARGE(600004),
    INVOICE_TOTAL_TOO_LARGE(600005),
    INVOICE_SUBMIT_VERIFY_ERROR(600009),

    SHIPPING_PRINT_NO_TRACKING(800000),

    FEDEX_API_RETURN_CODE(900000),

    API_NEED_WARN_CODE(900009);

    // All Exception error code should be start with 500xxx


    // All Exception error code should be start with 500xxx


    private int value;
    private static HashMap<Integer, AutoBestErrorCode> integerMap = new HashMap<Integer, AutoBestErrorCode>();

    AutoBestErrorCode(int value) {
        this.value = value;
    }

    @JsonValue
    public int getValue() {
        return value;
    }

    static {
        for (AutoBestErrorCode status : AutoBestErrorCode.values()) {
            integerMap.put(status.getValue(), status);
        }
    }

    public static AutoBestErrorCode valueOf(Integer value) {
        return (AutoBestErrorCode) integerMap.get(value);
    }
}